#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "logic/dataDefination.h"

class TabWidget;
class UserSetting;

namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    void login();

signals:
    void closeWindow();
    void sendMessage(const QString &ip, const QString &message);
    void stopChating(const QString &ip);
    void login(const QString &userName);

public slots:
    void onNetworkStatusChanged(eNetworkStatus networkStatus);
    void onLoginResultReceived(eLoginStatus loginStatus);
    void onContactListUpdated(const QList<userInfo> &contactList);
    void onMessageUpdated(const QString &ip, const QList<recordInfo> &messageList);
    void onUserNameUpdated(const QString &userName);

private slots:
    void onSettingAction();
    void onAboutAction();

    void testNetworkStatusChanged();
    void testLoginResultReceived();
    void testContactListUpdated();
    void testMessageUpdated();
    void testUserNameUpdated();

protected:
    void closeEvent(QCloseEvent * event);

private:
    bool getUserNameFromDialog(QString &newUserName);
    void createMenus();
    void createTestMenu();

private:
    QString mUserName;
    Ui::MainWindow *mUi;
    TabWidget *mTabWidget;
    UserSetting *mSetting;
};

#endif // MAINWINDOW_H

